package com.study.pattern.observer.vo;

import static com.study.module.MyUtils.waiting;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

public class Lady {

	Logger logger = LoggerFactory.getLogger(this.getClass());
	LadyData data = new LadyData();
	boolean needTerminate = false;

	private Lady(){
		data.setInterval(3000);
		data.setMsg("오빠아앙~~^^");
	}
	
	public void update(LadyData ladyData){
		data.setInterval(ladyData.getInterval());
		data.setMsg(ladyData.getMsg());
	}
	
	public void chant(){
		while(true){
			if(needTerminate)return;
			waiting(data.interval);
			logger.debug("{} 초 마다 '{}'을 을 외칩니다.",new Object[]{(data.interval/1000),data.msg});
		}
	}
	
	public void terminate() {
		this.needTerminate = true;
	}

	public static Lady newInstance() {
		return new Lady();
	}
}
